package com.blb.zycommunity.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.blb.zycommunity.entity.SysRole;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 角色信息表 Mapper 接口
 * </p>
 *
 * @author chenheng
 * @since 2023-11-20
 */
public interface SysRoleMapper extends BaseMapper<SysRole> {

    List<SysRole> selectAllRoles();

    /**
     *角色列表
     * @return
     */
    @Select("select * from sys_role  order by role_sort")
    List<SysRole> getRole();


    @Select("select * from sys_role")
    IPage<SysRole> getRolePage(Long current, Long size);


    IPage<SysRole> getSysRolePage(Page<SysRole> page, String name, String key, String status, LocalDateTime createTime, LocalDateTime updateTime);


    @Select("insert into sys_role_menu (role_id,menu_id)  values(#{roleId},#{menuIds})")
    void addInsert(Long roleId, Object menuIds);


    @Select("delete from sys_role_menu  where role_id = #{roleId}")
    void deleteById(Long roleId);

    @Select("update  sys_role_menu set menu_id =#{menuIds}  where  role_id = #{roleId}")
    void Update(Long roleId, Object menuIds);


    /**
     * 根据角色id删除角色信息
     * @param roleId
     */
    @Select("delete from sys_role  where role_id = #{roleId}")
    void deleteByRoleId(Object roleId);

    /**
     * 分页查询
     */
    Page<SysRole> selectPageVo(Page<SysRole> pageRole,String name, String key, String createTime, String status);

}
